using System.Collections.Generic;
using System.Xml;
using System.Xml.Linq;
using SharePointUtilitiesForDevelopers.Mapper;

namespace SharePointUtilitiesForDevelopers.Gateway
{
    /// <summary>
    /// Defines the interface for a gateway to the SharePoint Lists service.
    /// </summary>
    public interface ISharePointListsServiceGateway
    {

        /// <summary>
        /// Deletes list items in the specified list / view.
        /// </summary>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="viewName">Name of the view.</param>
        /// <param name="queryXml">The query XML.</param>
        /// <param name="batchSize">Size of the batch.</param>
        void DeleteListItems(
            string siteUrl,
            string listName,
            string viewName,
            XmlElement queryXml,
            int batchSize);

        /// <summary>
        /// Gets the list items.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="listName">Name or Guid of the list.</param>
        /// <param name="viewName">Guid of the view.</param>
        /// <param name="queryXml">The query.</param>
        /// <param name="viewFieldsXml">The view fields.</param>
        /// <param name="rowLimit">The row limit.</param>
        /// <param name="queryOptions">The query options.</param>
        /// <param name="webId">The web id.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns>A list of <see cref="TDomainObject"/> objects.</returns>
        IEnumerable<TDomainObject> GetListItems<TDomainObject>(
            string siteUrl,
            string listName,
            string viewName,
            XmlElement queryXml,
            XmlElement viewFieldsXml,
            string rowLimit,
            XmlElement queryOptions,
            string webId,
            IMapper<XElement, TDomainObject> mapper);

        /// <summary>
        /// Gets a list content type.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="contentTypeId">The content type id.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns>A <see cref="TDomainObject"/>.</returns>
        TDomainObject GetListContentType<TDomainObject>(
            string siteUrl,
            string listName,
            string contentTypeId,
            IMapper<XElement, TDomainObject> mapper);

        /// <summary>
        /// Gets the specified list.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="listName">The list name.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns>A <see cref="TDomainObject"/>.</returns>
        TDomainObject GetList<TDomainObject>(
            string siteUrl,
            string listName,
            IMapper<XElement, TDomainObject> mapper);

        /// <summary>
        /// Gets the lists in the specified web.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns>A list of <see cref="TDomainObject"/> objects.</returns>
        IEnumerable<TDomainObject> GetLists<TDomainObject>(
            string siteUrl,
            IMapper<XElement, TDomainObject> mapper);

        /// <summary>
        /// Gets the fields in the specified list.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site url.</param>
        /// <param name="listName">The list name.</param>
        /// <param name="mapper"></param>
        /// <returns>A list of <see cref="TDomainObject"/> objects.</returns>
        IEnumerable<TDomainObject> GetListFields<TDomainObject>(
            string siteUrl,
            string listName,
            IMapper<XElement, TDomainObject> mapper);
        
        /// <summary>
        /// Gets the content types.
        /// </summary>
        /// <typeparam name="TDomainObject">The type of the domain object.</typeparam>
        /// <param name="siteUrl">The site URL.</param>
        /// <param name="listName">Name of the list.</param>
        /// <param name="mapper">The mapper.</param>
        /// <returns>A list of <see cref="TDomainObject"/> objects.</returns>
        IEnumerable<TDomainObject> GetListContentTypes<TDomainObject>(
            string siteUrl, 
            string listName,
            IMapper<XElement, TDomainObject> mapper);
    }
}